package view
{
	import com.bit101.components.Text;
	
	import flash.display.Sprite;
	import flash.text.TextField;
	
	public class TotalPanle extends Sprite
	{
		private var title:TextField;
		private var addPrice:TextField;
		private var price:TextField;
		private var info:TextField;
		public var resultPrice:int;
		public function TotalPanle()
		{
			this.x = 170;
			this.y = 700;
			init();
		}
		private function init():void{
			title = new TextField;
			title.width = 70;
			title.height = 30;
			title.selectable = false;
			title.htmlText = "<font color='#666666' size='14'><b>特殊要求</b></font>";
			this.addChild(title);
			
			addPrice = new TextField;
			addPrice.width = 350;
			addPrice.height = 60;
			addPrice.selectable = false;
			addPrice.multiline = true;
			addPrice.wordWrap = true;
			//addPrice.htmlText = "<font color='#666666'>正面打印加10元，背面加10元，胸标10元</font>";
			this.addChild(addPrice);
			addPrice.x = 0;
			addPrice.y = 30;
			
			price = new TextField;
			price.width = 300;
			price.height = 45;
			price.selectable = false;
			price.multiline = true;
			price.wordWrap = true;
			//price.htmlText = "<font color='#ff6600' size='40'><b>总价200</b></font>";
			this.addChild(price);
			price.x = 0;
			price.y = 78;
			
			info = new TextField;
			info.width = 400;
			info.height = 70;
			info.selectable = false;
			//info.htmlText = "<font color='#666666' size='14'>仅需178元，让你获得超高人气，生活倍添乐趣\n\n根据定制复杂度，您会在2-7内收到货物，请耐心等待</font>";
			info.htmlText = "<font color='#666666' size='14'>根据定制复杂度，您会在2-7内收到货物，请耐心等待</font>";
			this.addChild(info);
			info.x = 0;
			info.y = 130;
			
		}
		public function setSource(ary:Array,allprice:int,num:int=1):void{
			var str:String = "";
			var p:int;
			var num:int;
			ary.sortOn("price", Array.NUMERIC | Array.DESCENDING);
			if(ary.length != 0){
				str = '打印 ';
				str += ary[0].name + "(价格" + ary[0].price + "，免费赠送) ";
			}else{
				str = "";
			}
			
			for(var i:int=1;i<ary.length;i++){
				str += ary[i].name + "加" + ary[i].price*num + "(" + ary[i].price + "×" + num + "件)元 ";
				p += ary[i].price*num;
			}
			addPrice.htmlText = "<font color='#666666'>" + str + "</font>";
			price.htmlText = "<font color='#ff6600' size='40'><b>总价" + (allprice+p) + "</b></font>";
			info.htmlText = "<font color='#666666' size='14'>仅需" + (allprice+p) + "元，让你获得超高人气，生活倍添乐趣\n\n根据定制复杂度，您会在2-7内收到货物，请耐心等待</font>";
			resultPrice = allprice+p;
		}
	}
}